
#include "pt_btnsetting.h"

static int            btn_is_update = 0;
static pt_btn_info_t  btn_left;
static pt_btn_info_t  btn_mid;
static pt_btn_info_t  btn_right;

int pt_btn_init_para(void)
{
    memset(&btn_left,0,sizeof(pt_btn_info_t));
    memset(&btn_mid,0,sizeof(pt_btn_info_t));
    memset(&btn_right,0,sizeof(pt_btn_info_t));

    snprintf(btn_left.buttonName,STR_LEN,"%s","照明");
    snprintf(btn_mid.buttonName,STR_LEN,"%s","雾冷水");
    snprintf(btn_right.buttonName,STR_LEN,"%s","开启");

    btn_is_update = 0;

    return 0;
}


int pt_btn_left_setting(
        char* btn_tKey,
        char* btn_buttonName,
        char* btn_roomId,
        char* btn_roomName,
        char* btn_tDesc,
        int   btn_buttonType,
        char* btn_buttonTypeName,
        char* btn_actionId,
        char* btn_fastId,
        char* btn_deviceType,
        char* btn_actionName,
        int   btn_radioButtonState,
        int   btn_voiceButtonStatee,
        char* btn_command
    )
{
    memset(&btn_left,0,sizeof(pt_btn_info_t));

    if(btn_tKey){
        snprintf(btn_left.tKey,STR_LEN,"%s",btn_tKey);
    }
    if(btn_buttonName){
        snprintf(btn_left.buttonName,STR_LEN,"%s",btn_buttonName);
    }   
    if(btn_roomId){
        snprintf(btn_left.roomId,STR_LEN,"%s",btn_roomId);
    }   
    if(btn_roomName){
        snprintf(btn_left.roomName,STR_LEN,"%s",btn_roomName);
    }   
    if(btn_tDesc){
        snprintf(btn_left.tDesc,STR_LEN,"%s",btn_tDesc);
    }  

    btn_left.buttonType = btn_buttonType;
    if(btn_buttonTypeName){
        snprintf(btn_left.buttonTypeName,STR_LEN,"%s",btn_buttonTypeName);
    }  
    if(btn_actionId){
        snprintf(btn_left.actionId,STR_LEN,"%s",btn_actionId);
    } 
    if(btn_fastId){
        snprintf(btn_left.fastId,STR_LEN,"%s",btn_fastId);
    } 
    if(btn_deviceType){
        snprintf(btn_left.deviceType,STR_LEN,"%s",btn_deviceType);
    } 
    if(btn_actionName){
        snprintf(btn_left.actionName,STR_LEN,"%s",btn_actionName);
    } 
    btn_left.radioButtonState  = btn_radioButtonState;
    btn_left.voiceButtonStatee = btn_voiceButtonStatee;

    if(btn_command){
        snprintf(btn_left.command,STR_LEN,"%s",btn_command);
    } 

    btn_is_update = 1;

    return 0;
}

int pt_btn_middle_setting(
        char* btn_tKey,
        char* btn_buttonName,
        char* btn_roomId,
        char* btn_roomName,
        char* btn_tDesc,
        int   btn_buttonType,
        char* btn_buttonTypeName,
        char* btn_actionId,
        char* btn_fastId,
        char* btn_deviceType,
        char* btn_actionName,
        int   btn_radioButtonState,
        int   btn_voiceButtonStatee,
        char* btn_command
    )
{
    memset(&btn_mid,0,sizeof(pt_btn_info_t));

    if(btn_tKey){
        snprintf(btn_mid.tKey,STR_LEN,"%s",btn_tKey);
    }
    if(btn_buttonName){
        snprintf(btn_mid.buttonName,STR_LEN,"%s",btn_buttonName);
    }   
    if(btn_roomId){
        snprintf(btn_mid.roomId,STR_LEN,"%s",btn_roomId);
    }   
    if(btn_roomName){
        snprintf(btn_mid.roomName,STR_LEN,"%s",btn_roomName);
    }   
    if(btn_tDesc){
        snprintf(btn_mid.tDesc,STR_LEN,"%s",btn_tDesc);
    }  

    btn_mid.buttonType = btn_buttonType;
    if(btn_buttonTypeName){
        snprintf(btn_mid.buttonTypeName,STR_LEN,"%s",btn_buttonTypeName);
    }  
    if(btn_actionId){
        snprintf(btn_mid.actionId,STR_LEN,"%s",btn_actionId);
    } 
    if(btn_fastId){
        snprintf(btn_mid.fastId,STR_LEN,"%s",btn_fastId);
    } 
    if(btn_deviceType){
        snprintf(btn_mid.deviceType,STR_LEN,"%s",btn_deviceType);
    } 
    if(btn_actionName){
        snprintf(btn_mid.actionName,STR_LEN,"%s",btn_actionName);
    } 
    btn_mid.radioButtonState  = btn_radioButtonState;
    btn_mid.voiceButtonStatee = btn_voiceButtonStatee;

    if(btn_command){
        snprintf(btn_mid.command,STR_LEN,"%s",btn_command);
    } 

    btn_is_update = 1;

    return 0;
}

int pt_btn_right_setting(
        char* btn_tKey,
        char* btn_buttonName,
        char* btn_roomId,
        char* btn_roomName,
        char* btn_tDesc,
        int   btn_buttonType,
        char* btn_buttonTypeName,
        char* btn_actionId,
        char* btn_fastId,
        char* btn_deviceType,
        char* btn_actionName,
        int   btn_radioButtonState,
        int   btn_voiceButtonStatee,
        char* btn_command
    )
{
    memset(&btn_right,0,sizeof(pt_btn_info_t));

    if(btn_tKey){
        snprintf(btn_right.tKey,STR_LEN,"%s",btn_tKey);
    }
    if(btn_buttonName){
        snprintf(btn_right.buttonName,STR_LEN,"%s",btn_buttonName);
    }   
    if(btn_roomId){
        snprintf(btn_right.roomId,STR_LEN,"%s",btn_roomId);
    }   
    if(btn_roomName){
        snprintf(btn_right.roomName,STR_LEN,"%s",btn_roomName);
    }   
    if(btn_tDesc){
        snprintf(btn_right.tDesc,STR_LEN,"%s",btn_tDesc);
    }  

    btn_right.buttonType = btn_buttonType;
    if(btn_buttonTypeName){
        snprintf(btn_right.buttonTypeName,STR_LEN,"%s",btn_buttonTypeName);
    }  
    if(btn_actionId){
        snprintf(btn_right.actionId,STR_LEN,"%s",btn_actionId);
    } 
    if(btn_fastId){
        snprintf(btn_right.fastId,STR_LEN,"%s",btn_fastId);
    } 
    if(btn_deviceType){
        snprintf(btn_right.deviceType,STR_LEN,"%s",btn_deviceType);
    } 
    if(btn_actionName){
        snprintf(btn_right.actionName,STR_LEN,"%s",btn_actionName);
    } 
    btn_right.radioButtonState  = btn_radioButtonState;
    btn_right.voiceButtonStatee = btn_voiceButtonStatee;

    if(btn_command){
        snprintf(btn_right.command,STR_LEN,"%s",btn_command);
    } 

    btn_is_update = 1;

    return 0;
}

char* btn_left_get_buttonName(void)
{
    return btn_left.buttonName;
}
char* btn_middle_get_buttonName(void)
{
    return btn_mid.buttonName;
}
char* btn_right_get_buttonName(void)
{
    return btn_right.buttonName;
}

int btn_get_update_flag(void)
{
    return btn_is_update;
}

int btn_set_update_flag(int flag)
{
    btn_is_update = flag;
    return 0;
}

int btn_left_is_radio(void)
{
    return btn_left.radioButtonState;
}
int btn_middle_is_radio(void)
{
    return btn_mid.radioButtonState;
}
int btn_right_is_radio(void)
{
    return btn_right.radioButtonState;
}
